﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

using JigLibX.Physics;
using JigLibX.Collision;
using JigLibX.Math;
using JigLibX.Geometry;

namespace helicopterFight
{
    public class Fizyka
    {
        PhysicsSystem physys;
        CollisionSystemSAP phycol;


        public void init()
        {
            physys = new JigLibX.Physics.PhysicsSystem();
            phycol = new JigLibX.Collision.CollisionSystemSAP();
            physys.CollisionSystem = phycol;
            physys.Gravity = Vector3.Zero;
            //bodBox2.Immovable = true;
        }

        public void update()
        {
            physys.Integrate(0.01f);
        }

        public static void SetMass(Body body, CollisionSkin skin, float mass)
        {
            PrimitiveProperties primitiveProperties = new PrimitiveProperties(
            PrimitiveProperties.MassDistributionEnum.Solid,
            PrimitiveProperties.MassTypeEnum.Mass, mass);
            float junk;
            Vector3 com;
            Matrix it;
            Matrix itCoM;
            skin.GetMassProperties(primitiveProperties, out junk, out com, out it, out itCoM);
            body.BodyInertia = itCoM;
            body.Mass = junk;
            skin.ApplyLocalTransform(new Transform(-com, Matrix.Identity));
        }
    }

}
